import * as qiniu from 'qiniu-js'

export function uploadFile(token,file){

    return new Promise( (resolve,reject) =>{
        const key = String(Date.parse(new Date())) + '.png'

        var observable = qiniu.upload(file, key, token, null, null)
    
        var subscription = observable.subscribe(res =>{
        
        }, error =>{
            console.log(error)
            reject(error)
        },res => {
            console.log(res)
            resolve(res.key)
        }) // 这样传参形式也可以
    })

}

